﻿using System;
using System.ComponentModel;
using System.Windows.Media;


namespace Business.Compta
{
    public class Category : IComparable
    {
        private int idCategory;
        private String categoryName;
        private Color color;

        public int IdCategory
        {
            get
            {
                return idCategory;
            }
        }
        public String CategoryName
        {
            get
            {
                return categoryName;
            }
            set
            {
                this.categoryName = value;
            }
        }
        public Color Color
        {
            get
            {
                return color;
            }
            set
            {
                this.color = value;
            }
        }

        public Category()
        {
            this.idCategory = -1;
            this.Color = Color.FromArgb(255, 255, 255, 255);
        }
        public Category(int _idCategory, String _categoryName, Color _color)
        {
            this.idCategory = _idCategory;
            this.categoryName = _categoryName;
            this.color = _color;
        }
        public Category(int _idCategory, String _categoryName)
        {
            this.idCategory = _idCategory;
            this.categoryName = _categoryName;
        }

        public override string ToString()
        {
            return this.categoryName;
        }

        public int CompareTo(Object o)
        {
            Category c = (Category)o;
            return String.Compare(this.categoryName, c.categoryName);
        }

        public override Boolean Equals(Object o)
        {
            if (o is Category)
            {
                Category c = (Category)o;
                if (c.CategoryName != null && this.CategoryName != null && c.CategoryName.Equals(this.CategoryName))
                    return true;
            }
            return false;
        }
    }

    // pour un compte, un user prend 65% des dépenses de la category donnée
    public class CategoriesPerUser : ManageoNotifyPropertyChanged
    {
        private int id;

        public int Id
        {
            get
            {
                return id;
            }
            set
            {
                this.id = value;
            }
        }
        private int idUser;
        private int _idUser;
        public int IdUser
        {
            get
            {
                return this.idUser;
            }
            set
            {
                this.idUser = value;
                onPropertyChanged("IdUser");
            }
        }

        private int idAccount;
        public int IdAccount
        {
            get
            {
                return this.idAccount;
            }
            set
            {
                this.idAccount = value;
                onPropertyChanged("IdAccount");
            }
        }

        private Double percent;
        private Double _percent;
        public Double Percent
        {
            get
            {
                return this.percent;
            }
            set
            {
                this.percent = value;
                onPropertyChanged("Percent");
            }
        }

        private int idCategory;
        private int _idCategory;
        public int IdCategory
        {
            get
            {
                return this.idCategory;
            }
            set
            {
                this.idCategory = value;
                onPropertyChanged("IdCategory");
            }
        }



        public CategoriesPerUser(int _id, int _idUser, int _idCategory, Double _percent)
        {
            this.id = _id;
            this.idUser = _idUser;
            this.idCategory = _idCategory;
            this.percent = _percent;
            this._idUser = _idUser;
            this._idCategory = _idCategory;
            this._percent = _percent;
        }
        public CategoriesPerUser()
        {
            this.id = -1;
            this.idUser = -1;
            this.idCategory = -1;
            this.idAccount = -1;
            this.percent = 0;
        }

        public void commit()
        {
            this._idUser = idUser;
            this._idCategory = idCategory;
            this._percent = percent;
        }

        public void reject()
        {
            this.idUser = _idUser;
            this.idCategory = _idCategory;
            this.percent = _percent;
        }
    }

}
